#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<math.h>
int my_atoi(const char* str)
{
	assert(str);
	int ret = 0;
	int count=0;
	const char* tmp = str;
	int n = 1;
	while(*tmp && * str >= '0' && *str <= '9')
	{
		count++;
	    tmp++;
	}
	if (*tmp != 0)// 1 2 3
	{
		return 0;
	}
	while (count)
	{
		ret += ( (*(str + count - 1)) - '0' )* n;
		n *= 10;
		count--;
	}
	return ret;
}
int main()
{
	char str[20] = "12345";
	printf("%d\n", my_atoi(str));
	printf("%d\n", atoi(str));
	return 0;
}